package com.ruoyi.common.core.domain.entity;

import java.math.BigDecimal;
import java.util.Date;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseIdEntity;
import com.ruoyi.common.utils.StringUtils;
import lombok.Data;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;

/**
 * 用户对象 yh_member
 * 
 * @author ruoyi
 * @date 2023-06-06
 */
@Data
@ApiModel(value = "YhMember", description = "用户对象")
public class YhMember extends BaseIdEntity
{
    private static final long serialVersionUID = 1L;

    /** 用户ID */
    @ApiModelProperty("用户ID")
    private String id;

    /** 系统用户ID */
    @ApiModelProperty("系统用户ID")
    private String userId;

    /** 微信openID */
    @Excel(name = "微信openID")
    @ApiModelProperty("微信openID")
    private String openId;

    /** 推荐人ID */
    @Excel(name = "推荐人ID")
    @ApiModelProperty("推荐人ID")
    private String parentId;


    /** 会员上级昵称 */
    @Excel(name = "会员上级昵称")
    @ApiModelProperty("会员上级昵称")
    @TableField(exist = false)
    private String parentNickName;

    /** 会员昵称 */
    @Excel(name = "会员昵称")
    @ApiModelProperty("会员昵称")
    private String nickName;

    /** 会员头像 */
    @Excel(name = "会员头像")
    @ApiModelProperty("会员头像")
    private String face;

    /** 手机号码 */
    @Excel(name = "手机号码")
    @ApiModelProperty("手机号码")
    private String mobile;

    /** 会员等级（非会员默认1级） */
    @Excel(name = "会员等级", readConverterExp = "非=会员默认1级")
    @ApiModelProperty("会员等级（非会员默认1级）")
    private Integer memberLevel;

    /** 会员积分 */
    @Excel(name = "会员积分")
    @ApiModelProperty("会员积分")
    private Double point;

    /** 会员冻结积分 */
    @Excel(name = "会员冻结积分")
    @ApiModelProperty("会员冻结积分")
    private Double frozenPoint;

    /** 会员佣金 */
    @Excel(name = "会员佣金")
    @ApiModelProperty("会员佣金")
    private Double commission;

    /** 会员冻结佣金 */
    @Excel(name = "会员冻结佣金")
    @ApiModelProperty("会员冻结佣金")
    private Double frozenCommission;

    /** 分享图片地址 */
    @Excel(name = "分享图片地址")
    @ApiModelProperty("分享图片地址")
    private String shareImgUrl;

    /** 是否禁用（1禁用，0未禁用） */
    @Excel(name = "是否禁用", readConverterExp = "1=禁用，0未禁用")
    @ApiModelProperty("是否禁用（1禁用，0未禁用）")
    private Integer isDisable;

    /** 创建时间 */
    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /** 更新者 */
    @ApiModelProperty("更新者")
    private String updateBy;

    /** 更新时间 */
    @ApiModelProperty("更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    public void removeSensitive(){
        this.parentId = null;
        this.openId = null;
        this.commission = null;
        this.point = null;
        this.frozenPoint = null;
        this.frozenCommission = null;
        this.id = null;
        this.mobile = null;
        this.isDisable = null;
        this.memberLevel = null;
        this.updateTime = null;
        this.updateBy = null;
    }


    public <T> QueryWrapper<T> queryWrapper(){
        QueryWrapper<T> wrapper=new QueryWrapper<>();

        wrapper.eq(StringUtils.isNotEmpty(id),"id" , id);
        wrapper.eq(StringUtils.isNotEmpty(openId),"open_id" , openId);
        wrapper.eq(StringUtils.isNotEmpty(parentId),"parent_id" , parentId);
        wrapper.like(StringUtils.isNotEmpty(nickName),"m1.nick_name" , nickName);
        wrapper.eq(StringUtils.isNotEmpty(face),"face" , face);
        wrapper.eq(StringUtils.isNotEmpty(mobile),"m1.mobile" , mobile);
        wrapper.eq(memberLevel != null,"m1.member_level" , memberLevel);
        wrapper.eq(point != null,"point" , point);
        wrapper.eq(frozenPoint != null,"frozen_point" , frozenPoint);
        wrapper.eq(commission != null,"commission" , commission);
        wrapper.eq(frozenCommission != null,"frozen_commission" , frozenCommission);
        wrapper.eq(isDisable != null,"m1.is_disable" , isDisable);
        wrapper.orderByDesc("create_time");
        return wrapper;
    }

}
